package com.goodflower.goodflower.creat_mac;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.goodflower.goodflower.R;

public class Creat_mac_three extends AppCompatActivity {
    private EditText creat_mac_kongshi;//空气湿度阈值
    private EditText creat_mac_kongwen;//空气温度阈值
    private Button btn_creat_mac_three_next;//下一页按钮

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.creat_mac_three);
        //获取控件
        creat_mac_kongshi = (EditText) findViewById(R.id.creat_mac_kongshi);
        creat_mac_kongwen = (EditText) findViewById(R.id.creat_mac_kongwen);
        btn_creat_mac_three_next = (Button) findViewById(R.id.btn_creat_mac_three_next);
        //获取上一页的数据
        Intent from_second_intent = getIntent();
        final String mac_name = from_second_intent.getStringExtra("mac_name");
        final String mac_mac = from_second_intent.getStringExtra("mac_mac");

        //下一步按钮点击事件
        btn_creat_mac_three_next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String mac_kongwen = creat_mac_kongwen.getText().toString();
                String mac_kongshi = creat_mac_kongshi.getText().toString();
                if (mac_kongshi == null || mac_kongwen == null || mac_kongshi.isEmpty() || mac_kongwen.isEmpty()) {
                    Toast.makeText(Creat_mac_three.this, "您必须输设定空气的温湿度阈值", Toast.LENGTH_LONG).show();
                } else {
                    Intent intent = new Intent(Creat_mac_three.this, Creat_mac_four.class);
                    intent.putExtra("mac_name", mac_name);
                    intent.putExtra("mac_mac", mac_mac);
                    intent.putExtra("mac_kongshi", mac_kongshi);
                    intent.putExtra("mac_kongwen", mac_kongwen);
                    startActivity(intent);

                }
            }
        });
    }
}
